#include "BrickList.h"


BrickList::BrickList(void)
{
}

BrickList::BrickList(int maxBrickNum)
{
	this->_maxBrickNum = maxBrickNum;
	this->_bricks = new Brick*[_maxBrickNum];

	this->_brickNum = 0;
}

BrickList::~BrickList(void)
{

}

void BrickList::Add(Brick brick)
{
	if (_brickNum < _maxBrickNum)
		_bricks[_brickNum++] = new Brick(brick);
}

void BrickList::Add(int x,int y, int Width, int Height, LPD3DXSPRITE spritehandler, LPDIRECT3DTEXTURE9 image)
{
	if (_brickNum < _maxBrickNum)
	{
		Brick b = Brick(x,y,Width, Height,spritehandler,image);
		_bricks[_brickNum++] = new Brick(b,spritehandler,image);
	}
}

void BrickList::Delete(int index)
{
	if (index>=0 && index < _brickNum)
		_brickNum--;
}

Brick* BrickList::Get(int index)
{
	return this->_bricks[index];
}

void BrickList::Render()
{
	for (int i=0;i<_brickNum;i++)
		_bricks[i]->Render();
}